package com.example.personnel_management_system.service.Impl;

import com.example.personnel_management_system.entity.Institution;
import com.example.personnel_management_system.mapper.InstitutionMapper;
import com.example.personnel_management_system.service.IInstitutionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InstitutionImplService implements IInstitutionService {

    @Autowired
    private InstitutionMapper institutionMapper;
    @Override
    public Integer insert(Institution institution) {
        if(institution.getiLevel()==1)
            institution.setiParent(0);
        return institutionMapper.insert(institution);
    }

    @Override
    public List<Institution> findall() {
        return institutionMapper.findall();
    }

    @Override
    public Institution findByIid(Integer Iid) {
        return institutionMapper.findByID(Iid);
    }

    @Override
    public Integer update(Institution institution) {
        return institutionMapper.update(institution);
    }

    @Override
    public List<Institution> findByParent(Integer iParent) {
        return institutionMapper.findByParent(iParent);
    }


}
